
<!doctype html>
<html>
<head>
<title>   </title>
<style>
  body{text-align:center;}  
  .title{background:#ccc;}
  table{height:200px;width:200px;font-size:12px;text-align:center;float:left;margin:10px;font-family:arial;}
</style>
</head>
<body>
    <?php
function king($n,$m){
    $monkey=range(1,$n);
    $i=0;
    while(count($monkey)>1){
        ++$i;
        $head=array_shift($monkey);
        if($i%$m!=0){
            array_push($monkey,$head);
        }
    }
    return $monkey[0];
    
}
echo king(10,7);

?>
</body>
</html>
